package com.scpii.api.persistence.push;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.scpii.api.domain.push.UserMessageDevices;

public interface UserMessageDevicesMapper {

	/**
	 * 根据对象进行查询
	 * 
	 * @param record
	 * @return
	 */
	List<UserMessageDevices> selectByObject(UserMessageDevices record);

	List<UserMessageDevices> androidPullMessage(UserMessageDevices record);
	
	/**
	 * 更改消息状态为已经拉取，避免重复拉取同一条消息
	 * 
	 * @param list
	 * @return
	 */
	int updateMessageStatusToHAS_PULL(List<Long> list);

	Long generateId();

	/**
	 * 插入一条用户消息设备记录
	 * @param record
	 * @return
	 */
	int insert(UserMessageDevices record);
	
	/**
	 * 查询需要给那些应用进行推送！其中只返回 messageId 和 appId
	 * @return
	 */
	List<UserMessageDevices> selectApp4Push();
	
	/**
	 * 根据messageId 和 appID 来查询推送的IOS_TOKENS
	 * @param umd
	 * @return
	 */
	List<String> selectIOSTokens(UserMessageDevices umd);
	
	/**
	 * 向APNS推送后，更新消息记录为已经推
	 * @param umd
	 * @return
	 */
	int updateMessageStatusToHAS_PUSH(@Param("umd")UserMessageDevices umd,@Param("list")List<String> list);
	
	int updateStatus4Test(@Param("userMessageDeviceId")Long userMessageDeviceId, @Param("messageStatus")Integer messageStatus);
	
	
	
	
	
	
	// ======================================================

	int deleteByPrimaryKey(Long id);

	int insertSelective(UserMessageDevices record);

	UserMessageDevices selectByPrimaryKey(Long id);

	int updateByPrimaryKeySelective(UserMessageDevices record);

	int updateByPrimaryKey(UserMessageDevices record);
}